Skip to content

Rel 1.15 bp 3233 2#3241

Closed
wild-endeavor wants to merge 2 commits into
masterfrom
rel-1.15-bp-3233-2
Closed

Rel 1.15 bp 3233 2#3241
wild-endeavor wants to merge 2 commits into
masterfrom
rel-1.15-bp-3233-2

Conversation

@wild-endeavor
Copy link
Copy Markdown
Contributor

@wild-endeavor wild-endeavor commented Apr 22, 2025

Summary by Bito

The pull request enhances Flytekit with improved subprocess signal handling, image specification capabilities, and runtime package management features. It introduces NoOpBuilder for image building and adds the RUNTIME_PACKAGES_ENV_NAME constant. The changes improve test coverage and update documentation baselines to reflect current code structure.

Unit tests added: False

Estimated effort to review (1-5, lower is better): 3

thomasjpfan and others added 2 commits April 22, 2025 14:51
* Adds ImageSpec.with_dev_dependencies

Signed-off-by: Thomas J. Fan <thomasjpfan@gmail.com>

* Fix

Signed-off-by: Thomas J. Fan <thomasjpfan@gmail.com>

* Add tests for noop builder

Signed-off-by: Thomas J. Fan <thomasjpfan@gmail.com>

* Use runtime_packages

Signed-off-by: Thomas J. Fan <thomasjpfan@gmail.com>

* Add docs abount how to use runtime packages

Signed-off-by: Thomas J. Fan <thomasjpfan@gmail.com>

* Less diffs

Signed-off-by: Thomas J. Fan <thomasjpfan@gmail.com>

* Fix formatting

Signed-off-by: Thomas J. Fan <thomasjpfan@gmail.com>

* Fix docstring

Signed-off-by: Thomas J. Fan <thomasjpfan@gmail.com>

* Dix docstring

Signed-off-by: Thomas J. Fan <thomasjpfan@gmail.com>

* Let pip default to user by itself to be more compatible

Signed-off-by: Thomas J. Fan <thomasjpfan@gmail.com>

---------

Signed-off-by: Thomas J. Fan <thomasjpfan@gmail.com>
* Image spec builder options

Provide the ability to specify image `builder` specific options per
Image Spec.

Signed-off-by: Mike Hotan <mike@union.ai>

* Add builder_options validation

Signed-off-by: Mike Hotan <mike@union.ai>

* updates

Signed-off-by: Mike Hotan <mike@union.ai>

---------

Signed-off-by: Mike Hotan <mike@union.ai>
@flyte-bot
Copy link
Copy Markdown
Contributor

flyte-bot commented Apr 22, 2025

Code Review Agent Run #5ddb1b

Actionable Suggestions - 2
  • flytekit/bin/entrypoint.py - 1
    • Subprocess call with untrusted input · Line 66-71
  • flytekit/image_spec/image_spec.py - 1
    • Missing initialization for builder_options attribute · Line 103-103
Additional Suggestions - 10
  • flytekit/bin/entrypoint.py - 4
    • Signal handler not restored after subprocess completes · Line 66-75
    • Use list instead of List annotation · Line 66-66
    • Missing return type for private function · Line 70-70
    • Missing return type for array index function · Line 78-78
  • flytekit/image_spec/noop_builder.py - 2
    • Import statement incorrectly placed inside method · Line 14-16
    • Use TypeError for invalid type checks · Line 12-12
  • flytekit/image_spec/image_spec.py - 3
  • flytekit/core/python_auto_container.py - 1
    • Move imports to type-checking block · Line 12-12
Review Details
  • Files reviewed - 9 · Commit Range: 2452b29..f24324c
    • flytekit/bin/entrypoint.py
    • flytekit/core/constants.py
    • flytekit/core/python_auto_container.py
    • flytekit/image_spec/__init__.py
    • flytekit/image_spec/image_spec.py
    • flytekit/image_spec/noop_builder.py
    • pydoclint-errors-baseline.txt
    • tests/flytekit/unit/core/image_spec/test_image_spec.py
    • tests/flytekit/unit/core/image_spec/test_noop_builder.py
  • Files skipped - 0
  • Tools
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful
    • MyPy (Static Code Analysis) - ✔︎ Successful
    • Astral Ruff (Static Code Analysis) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers a full AI review.

Refer to the documentation for additional commands.

Configuration

This repository uses code_review_bito You can customize the agent settings here or contact your Bito workspace admin at haytham@union.ai.

Documentation & Help

AI Code Review powered by Bito Logo

@flyte-bot
Copy link
Copy Markdown
Contributor

Changelist by Bito

This pull request implements the following key changes.

Key Change Files Impacted
New Feature - New Features Added

constants.py - Introduced RUNTIME_PACKAGES_ENV_NAME constant for managing runtime package installations.

__init__.py - Registered NoOpBuilder and updated image build engine registrations.

image_spec.py - Enhanced image specification with runtime package and builder options functionalities along with doc improvements.

noop_builder.py - Added a new NoOpBuilder implementation for image building.

Feature Improvement - Improved Subprocess Signal Handling

entrypoint.py - Refactored subprocess management with a dedicated function for SIGTERM handling and updated runtime package imports.

Other Improvements - Minor Import Updates

python_auto_container.py - Updated import to include RUNTIME_PACKAGES_ENV_NAME.

Testing - Enhanced Test Coverage

test_image_spec.py - Extended tests to validate builder options and runtime package behaviors in image spec.

test_noop_builder.py - Implemented tests for NoOpBuilder functionality and error handling.

Documentation - Updated Docstring and Lint Baseline

pydoclint-errors-baseline.txt - Revised baseline error logs to align class and method docstrings with actual attributes.

Comment on lines +66 to +71
def _run_subprocess(cmd: List[str], env: Optional[dict] = None) -> int:
"""Run cmd with proper SIGTERM handling."""
p = subprocess.Popen(cmd, env=env)

def handle_sigterm(signum, frame):
logger.info(f"passing signum {signum} [frame={frame}] to subprocess")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Subprocess call with untrusted input

Security issue on line 68: subprocess.Popen(cmd, env=env) may execute untrusted input. Consider validating the cmd parameter or using shlex.quote() if the command includes user input.

Code suggestion
Check the AI-generated fix before applying
Suggested change
def _run_subprocess(cmd: List[str], env: Optional[dict] = None) -> int:
"""Run cmd with proper SIGTERM handling."""
p = subprocess.Popen(cmd, env=env)
def handle_sigterm(signum, frame):
logger.info(f"passing signum {signum} [frame={frame}] to subprocess")
def _run_subprocess(cmd: List[str], env: Optional[dict] = None) -> int:
"""Run cmd with proper SIGTERM handling."""
# Ensure cmd is a list of strings to prevent shell injection
if not all(isinstance(arg, str) for arg in cmd):
raise ValueError("All command arguments must be strings")
p = subprocess.Popen(cmd, env=env, shell=False)
def handle_sigterm(signum, frame):
logger.info(f"passing signum {signum} [frame={frame}] to subprocess")

Code Review Run #5ddb1b


Should Bito avoid suggestions like this for future reviews? (Manage Rules)

  • Yes, avoid them

@@ -95,6 +102,8 @@ class ImageSpec:
source_copy_mode: Optional[CopyFileDetection] = None
copy: Optional[List[str]] = None
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing initialization for builder_options attribute

The _update_attribute method now handles dictionaries but with_builder_options method doesn't properly initialize the builder_options attribute when it's None. This could cause a TypeError when trying to update a non-existent dictionary.

Code suggestion
Check the AI-generated fix before applying
Suggested change
copy: Optional[List[str]] = None
copy: Optional[List[str]] = None
builder_options: Optional[Dict[str, Any]] = None

Code Review Run #5ddb1b


Should Bito avoid suggestions like this for future reviews? (Manage Rules)

  • Yes, avoid them

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 22, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 94.75%. Comparing base (e1518f6) to head (f24324c).
Report is 33 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff             @@
##           master    #3241       +/-   ##
===========================================
+ Coverage   52.34%   94.75%   +42.40%     
===========================================
  Files         213       55      -158     
  Lines       22312     2077    -20235     
  Branches     2916        0     -2916     
===========================================
- Hits        11680     1968     -9712     
+ Misses       9946      109     -9837     
+ Partials      686        0      -686     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants